import 'package:finance_app/src/entities/business_contact_entity.dart';

businessContactEntityFromJson(BusinessContactEntity data, Map<String, dynamic> json) {
	if (json['data_type'] != null) {
		data.dataType = json['data_type'].toString();
	}
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['company_id'] != null) {
		data.companyId = json['company_id'] is String
				? int.tryParse(json['company_id'])
				: json['company_id'].toInt();
	}
	if (json['primary_contact_id'] != null) {
		data.primaryContactId = json['primary_contact_id'];
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['country_code'] != null) {
		data.countryCode = json['country_code'].toString();
	}
	if (json['phone_number'] != null) {
		data.phoneNumber = json['phone_number'].toString();
	}
	if (json['email'] != null) {
		data.email = json['email'].toString();
	}
	if (json['website'] != null) {
		data.website = json['website'].toString();
	}
	if (json['is_taxable'] != null) {
		data.isTaxable = json['is_taxable'] is String
				? int.tryParse(json['is_taxable'])
				: json['is_taxable'].toInt();
	}
	if (json['address_country'] != null) {
		data.addressCountry = json['address_country'].toString();
	}
	if (json['address_city'] != null) {
		data.addressCity = json['address_city'].toString();
	}
	if (json['address_postal_code'] != null) {
		data.addressPostalCode = json['address_postal_code'].toString();
	}
	if (json['address_line_1'] != null) {
		data.addressLine1 = json['address_line_1'].toString();
	}
	if (json['address_line_2'] != null) {
		data.addressLine2 = json['address_line_2'].toString();
	}
	if (json['is_favorite'] != null) {
		data.isFavorite = json['is_favorite'] is String
				? int.tryParse(json['is_favorite'])
				: json['is_favorite'].toInt();
	}
	if (json['is_client'] != null) {
		data.isClient = json['is_client'] is String
				? int.tryParse(json['is_client'])
				: json['is_client'].toInt();
	}
	if (json['is_supplier'] != null) {
		data.isSupplier = json['is_supplier'] is String
				? int.tryParse(json['is_supplier'])
				: json['is_supplier'].toInt();
	}
	if (json['is_overdue'] != null) {
		data.isOverdue = json['is_overdue'] is String
				? int.tryParse(json['is_overdue'])
				: json['is_overdue'].toInt();
	}
	if (json['total_credit'] != null) {
		data.totalCredit = json['total_credit'] is String
				? num.tryParse(json['total_credit'])
				: json['total_credit'];
	}
	if (json['total_debit'] != null) {
		data.totalDebit = json['total_debit'] is String
				? num.tryParse(json['total_debit'])
				: json['total_debit'];
	}
	if (json['total_unpaid_credit'] != null) {
		data.totalUnpaidCredit = json['total_unpaid_credit'] is String
				? num.tryParse(json['total_unpaid_credit'])
				: json['total_unpaid_credit'];
	}
	if (json['total_unpaid_debit'] != null) {
		data.totalUnpaidDebit = json['total_unpaid_debit'] is String
				? num.tryParse(json['total_unpaid_debit'])
				: json['total_unpaid_debit'];
	}
	if (json['paying_amount'] != null) {
		data.payingAmount = json['paying_amount'] is String
				? num.tryParse(json['paying_amount'])
				: json['paying_amount'];
	}
	if (json['receiving_amount'] != null) {
		data.receivingAmount = json['receiving_amount'] is String
				? num.tryParse(json['receiving_amount'])
				: json['receiving_amount'];
	}
	if (json['enabled'] != null) {
		data.enabled = json['enabled'] is String
				? int.tryParse(json['enabled'])
				: json['enabled'].toInt();
	}
	if (json['created_by'] != null) {
		data.createdBy = json['created_by'];
	}
	if (json['created_at'] != null) {
		data.createdAt = json['created_at'].toString();
	}
	if (json['updated_at'] != null) {
		data.updatedAt = json['updated_at'].toString();
	}
	if (json['address_unit'] != null) {
		data.addressUnit = json['address_unit'].toString();
	}
	if (json['enable_address'] != null) {
		data.enableAddress = json['enable_address'] is String
				? int.tryParse(json['enable_address'])
				: json['enable_address'].toInt();
	}
	if (json['last_transaction_at'] != null) {
		data.lastTransactionAt = json['last_transaction_at'].toString();
	}
	if (json['unpaid_invoice_overdue_amount'] != null) {
		data.unpaidInvoiceOverdueAmount = json['unpaid_invoice_overdue_amount'] is String
				? num.tryParse(json['unpaid_invoice_overdue_amount'])
				: json['unpaid_invoice_overdue_amount'];
	}
	if (json['unpaid_bill_overdue_amount'] != null) {
		data.unpaidBillOverdueAmount = json['unpaid_bill_overdue_amount'] is String
				? num.tryParse(json['unpaid_bill_overdue_amount'])
				: json['unpaid_bill_overdue_amount'];
	}
	return data;
}

Map<String, dynamic> businessContactEntityToJson(BusinessContactEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['data_type'] = entity.dataType;
	data['id'] = entity.id;
	data['company_id'] = entity.companyId;
	data['primary_contact_id'] = entity.primaryContactId;
	data['name'] = entity.name;
	data['country_code'] = entity.countryCode;
	data['phone_number'] = entity.phoneNumber;
	data['email'] = entity.email;
	data['website'] = entity.website;
	data['is_taxable'] = entity.isTaxable;
	data['address_country'] = entity.addressCountry;
	data['address_city'] = entity.addressCity;
	data['address_postal_code'] = entity.addressPostalCode;
	data['address_line_1'] = entity.addressLine1;
	data['address_line_2'] = entity.addressLine2;
	data['is_favorite'] = entity.isFavorite;
	data['is_client'] = entity.isClient;
	data['is_supplier'] = entity.isSupplier;
	data['is_overdue'] = entity.isOverdue;
	data['total_credit'] = entity.totalCredit;
	data['total_debit'] = entity.totalDebit;
	data['total_unpaid_credit'] = entity.totalUnpaidCredit;
	data['total_unpaid_debit'] = entity.totalUnpaidDebit;
	data['paying_amount'] = entity.payingAmount;
	data['receiving_amount'] = entity.receivingAmount;
	data['enabled'] = entity.enabled;
	data['created_by'] = entity.createdBy;
	data['created_at'] = entity.createdAt;
	data['updated_at'] = entity.updatedAt;
	data['address_unit'] = entity.addressUnit;
	data['enable_address'] = entity.enableAddress;
	data['last_transaction_at'] = entity.lastTransactionAt;
	data['unpaid_invoice_overdue_amount'] = entity.unpaidInvoiceOverdueAmount;
	data['unpaid_bill_overdue_amount'] = entity.unpaidBillOverdueAmount;
	return data;
}